<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .float-box-father{
            /**方式3 创建一个会包含这个浮动的BFC，通常的做法是设置父元素 overflow: auto **/
            /* overflow: auto; */

            /* display: flow-root */

            /** 方式4 浮动元素的父元素添加高度**/
            /* height: 250px; */

           

        }
        .float-box-father:after{
            /**方式2 浮动元素的父元素添加伪元素：after，并设置如下样式**/
            /* clear: both;
            content: '111';
            display: block;
            height: 0;
            visibility: hidden; */
        }
        .float-box{
            float: left;
            box-sizing: border-box;
            width: 50%;
            height: 50px;
            border: 1px solid beige;
            background-color: green;
            opacity: 0.5;
        }
        
        .box{
            width: 100%;
            height: 100px;
            background-color: blue;
        }
       
        
    </style>
</head>
<body>
        <div class="float-box-father">
            <div class="float-box"></div>
            <div class="float-box"></div>
            <div class="float-box"></div>
            <div class="float-box"></div>
            <div class="float-box"></div>
            <div class="float-box"></div>
            <div class="float-box"></div>
            <div class="float-box"></div>
            <div class="float-box last-float-box"></div>
        <!--方式1：在box-2前面新增一个div，添加样式clear:both;-->
        <!-- <div style="clear: both;"></div> -->
        </div>
        <div class="box"></div>
</body>
</html>